import { RouteRecordRaw, createRouter, createWebHistory } from "vue-router";
import Layout from '@/layout/Index.vue'

const routes: Array<RouteRecordRaw> = [
    {
        path: "/",
        component: Layout,
        redirect: "/dashboard",
        children: [
            {
                path: "/dashboard",
                name: "dashboard",
                component: () => import("@/views/dashboard/Index.vue"),
                meta: {
                    title: "首页",
                    icon: "HomeFilled",
                },
            }

        ]
    },
    {
        path: "/system",
        name: "system",
        component: Layout,
        meta: {
            title: "系统管理",
            icon: "Setting",
            roles: ["sys: manage"],
        },
        children: [
            {
                path: "/userList",
                name: "userList",
                component: () => import("@/views/system/user/UserList.vue"),
                meta: {
                    title: "用户管理",
                    icon: "User",
                    roles: ["sys: user"],
                },
            },
            {
                path: "/roleList",
                name: "roleList",
                component: () => import("@/views/system/role/RoleList.vue"),
                meta: {
                    title: "角色管理",
                    icon: "Avatar",
                    roles: ["sys: role"],
                },
            },
            {
                path: "/menuList",
                name: "menuList",
                component: () => import("@/views/system/menu/MenuList.vue"),
                meta: {
                    title: "菜单管理",
                    icon: "Menu",
                    roles: ["sys: menu"],
                },
            },
        ]
    },
    {
        path: "/booksRoot",
        name: "booksRoot",
        component: Layout,
        meta: {
            title: "图书管理",
            icon: "Setting",
            roles: ["sys:booksRoot"],
        },
        children: [
            {
                path: "/category",
                name: "category",
                component: () => import("@/views/booksRoot/category/CategoryList.vue"),
                meta: {
                    title: "图书分类",
                    icon: "Histogram",
                    roles: ["sys:category"],
                },
            },
            {
                path: "/bookList",
                name: "bookList",
                component: () => import("@/views/booksRoot/books/BooksList.vue"),
                meta: {
                    title: "图书信息",
                    icon: "Notebook",
                    roles: ["sys:books"],
                },
            }
        ]
    },
]
//创建路由对像
const router = createRouter({
    history: createWebHistory(),
    routes
})

//导出
export default router